package poo.exo13;

import poo.exo13.MonException;

public class Finally2{

	/**
	 * @param args
	 */
	
	public static void f(int n) throws MonException 
	{
		try {
			if(n>1)
			{
				throw new MonException("Dans Catch de f, n = "+String.valueOf(n) );
			}
		} catch (MonException me) {		
			System.out.println(me.getMessage());
			if(n==2)
			{
				Throwable Except = new MonException();
				Except.initCause(Except);
				try {

					throw Except;

				} catch (Throwable e) {
					System.out.println("Dans finally de f, n = "+n);
				}
			}		
		}finally {
			System.out.println("Dans finally de f, n = "+n);
		}	
	}
	
	public static void main(String[] args) {
		int n=0;
		try{
			for(n=1;n<5;n++) f(n);
		} catch (Exception e) {
			System.out.println("catch dans main - n = "+ n);
		} finally {
			System.out.println("dans finally de main - n = "+ n);
		}
	}

}
